package loan.calc.domain;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import loan.calc.constant.dict.FinalPeriodMergeTypeEnum;
import loan.calc.constant.dict.InstalmentResetFlagEnum;
import loan.calc.constant.dict.RepayFrequencyTypeEnum;
import loan.calc.constant.dict.RepayMethodDictEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;

@EqualsAndHashCode(callSuper = true)
@Data
@TableName("loan_repay_segment")
@Schema(description = "借据还款区段实体", name = "LoanRepaySegmentDO", title = "借据还款区段")
public class LoanRepaySegmentDO extends BaseEntity implements Serializable {

    /**
     * 主键id
     */
    @TableId
    @Schema(description = "借据还款区段编号")
    private Long segmentId;

    /**
     * 借据id
     */
    @Schema(description = "借据编号")
    private Long loanId;

    /**
     * 区段生效日期
     */
    @Schema(description = "区段生效日期")
    private LocalDate segmentStartDate;

    /**
     * 区段结束日期
     */
    @Schema(description = "区段结束日期")
    private LocalDate segmentMaturityDate;

    /**
     * 还款方式
     */
    @Schema(description = "还款方式")
    private RepayMethodDictEnum repayMethod;

    /**
     * 还款频率类型
     * 按月
     * 按季
     * 按双周
     * 一次
     * 指定周期
     * 固定季
     */
    @Schema(description = "还款频率类型")
    private RepayFrequencyTypeEnum repayFrequencyType;

    /**
     *
     * 当repayFrequencyType为指定周期时需要
     */
    @Schema(description = "指定周期的单位,当repayFrequencyType为指定周期时需要")
    private ChronoUnit repayFrequencyUnit;

    /**
     * 指定周期数
     * 选择1~366
     * 当repayFrequencyType为指定周期时需要
     */
    @Schema(description = "指定周期数")
    private Integer repayFrequency;

    /**
     * 期供金额
     */
    @Schema(description = "期供金额")
    private BigDecimal instalmentAmt;

    /**
     * 总期次
     */
    @Schema(description = "总期次")
    private Integer totalPeriod;

    /**
     * 当前期次
     */
    @Schema(description = "当前期次")
    private Integer currentPeriod;

    /**
     * 默认还款日
     */
    @Schema(description = "默认还款日")
    private Integer defaultRepayDay;

    /**
     * 首次还款日
     */
    @Schema(description = "首次还款日")
    private LocalDate firstRepaymentDate;

    /**
     * 上次还款日
     */
    @Schema(description = "上次还款日")
    private LocalDate lastRepaymentDate;

    /**
     * 下次还款日
     */
    @Schema(description = "下次还款日")
    private LocalDate nextRepaymentDate;

    /**
     * 末期是否合并
     */
    @Schema(description = "末期是否合并")
    private FinalPeriodMergeTypeEnum finalPeriodMergeType;

    /**
     * 本区段本金总额
     */
    @Schema(description = "本区段本金总额")
    private BigDecimal principalAmount;

    /**
     * 本区段本金余额
     */
    @Schema(description = "本区段本金余额")
    private BigDecimal principalBalance;

    /**
     * 是否更新期供金额标志
     */
    @Schema(description = "是否更新期供金额标志")
    private InstalmentResetFlagEnum psRestructureFlag;
}
